package com.syedu.cels.util;

import lombok.Data;

import java.util.List;

/**
 * description：分页整合对象
 */
@Data
public class PageBean<T> {
    private Integer pageNow;//当前页
    private Integer pageSize;//每页显示多少条记录
    private Integer totalPages;//总页数
    private Integer counts;//总记录数
    //private Boolean nextPage;//是否有下一页
    //private Boolean periousPage;//是否有上一页
    private List<T> datas;//分页数据

    public PageBean(Integer pageNow, Integer pageSize) {
        this.pageNow = pageNow;
        this.pageSize = pageSize;
    }

    public void setCounts(Integer counts) {
        this.counts = counts;
        if (counts % pageSize == 0) {
            totalPages = counts / pageSize;
        } else {
            totalPages = counts / pageSize + 1;
        }
    }
}